import random

def guess_game():
    print("请输入一个1-100之间的数字")
    random_number = random.randint(1, 100)
    guess = 0
    while guess!= random_number:
        guess = int(input("你猜的数字是："))
        if guess < random_number:
            print("小了，再试试！")
        elif guess > random_number:
            print("大了，再试试！")
    print("恭喜你，猜对了!")
    print("随机数是：", random_number)
guess_game()

print("======================================================================================")
import random

def guess_game():
    print("欢迎来到猜数字游戏！你初始金币为1200")
    global total_money
    total_money = 5000
    print("请输入一个1-100之间的数字")
    random_number = random.randint(1, 100)
    guess = 0
    while guess!= random_number:
        guess = int(input("你猜的数字是："))
        if guess < random_number:
            print("小了，再试试！")
        elif guess > random_number:
            print("大了，再试试！")
        if total_money >= 500:
            total_money -= 500
            print("你还有", total_money, "金币")
        else:
            print("你已经用完了你的金币，游戏结束！")
            break
        if(total_money < 500):
            break
        if guess == random_number:
            print("恭喜你，猜对了!获得3000金币！")
            print("随机数是：", random_number)
            total_money += 3000
            print("你目前的金币为：", total_money)
guess_game()

print("======================================================================================")


import random

def guess_game():
    temp = 1
    while temp == 1:
        print("请输入一个1-100之间的数字")
        random_number = random.randint(1, 100)
        guess = 0
        while guess!= random_number:
            guess = int(input("你猜的数字是："))
            if guess < random_number:
                print("小了，再试试！")
            elif guess > random_number:
                print("大了，再试试！")
        print("恭喜你，猜对了!")
        print("随机数是：", random_number)
        temp = int(input("是否继续玩游戏？1.继续 2.退出"))
        if temp == 2:
            break
guess_game()










